package com.yequan.designpattern.composite.safe;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yequan
 * @date 2019/12/11
 */
public class Folder extends File {

    /**
     * 用于存放子节点
     */
    private List<File> fileList = new ArrayList<>();

    public Folder(String name) {
        this.name = name;
    }

    @Override
    public void showSelf(int deep) {
        System.out.println("文件夹: " + name);
        for (File file : fileList) {
            file.showSelf(deep + 1);
        }
    }

    public void add(File file) {
        fileList.add(file);
    }

    public void remove(File file) {
        fileList.remove(file);
    }

    public List<File> getChild() {
        return fileList;
    }
}
